package com.example.onlineeducation.mapper

import com.example.onlineeducation.data.constant.ProStateErrorType
import com.example.onlineeducation.data.constant.UserSexType
import com.example.onlineeducation.data.entity.LoginUserInfoEntity
import com.example.onlineeducation.data.entity.ProInfoEntity
import com.example.onlineeducation.data.json.UserInfoJson
import com.yc.jetpacklib.extension.ycToNoEmpty
import com.yc.jetpacklib.mapper.IMapper

class GetUserInfoMapper : IMapper<UserInfoJson, LoginUserInfoEntity> {
    override fun map(input: UserInfoJson): LoginUserInfoEntity = LoginUserInfoEntity(
        input.name.ycToNoEmpty(),
        UserSexType.getName(input.sex),
        input.sex,
        input.projList?.map {
            ProInfoEntity(
                it?.id ?: "",
                it?.name.ycToNoEmpty(),
                it?.personTypeName ?: "无",
                it?.personTypeId,
                ProStateErrorType.getProStateName(it?.workState, it?.isBlack, it?.isStop),
                ProStateErrorType.proStatusIsOK(it?.workState, it?.isBlack, it?.isStop),
                ProStateErrorType.isProMonitor(it?.isPersonGroupMaster),
                it?.hasOfflinePermission ?: false
            )
        }
    )
}

